import request from '@/utils/request'
import axios from 'axios'

export function login(data) {
  return request({
    // url: '/vue-admin-template/user/login',
    url: '/online/authorization/auth/login',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/online/authorization/auth/user/info',
    method: 'get'
  })
}

export function getselfInfoFull() {
  return request({
    url: '/online/authorization/user-self/user/info',
    method: 'get'
  })
}

export function updateUserInfoFull(data) {
  return request({
    url: '/online/authorization/user-self/user/info/update',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    // url: '/vue-admin-template/user/logout',
    url: '/online/authorization/auth/logout',
    method: 'post'
  })
}

export function authCaptcha() {
  return axios({
    url: '/online/authorization/auth/verify/code',
    method: 'GET'
  })
}

export function getUserPage(params) {
  return request({
    url: '/online/authorization/user',
    method: 'GET',
    params
  })
}
export function getAllUser(params) {
  return request({
    url: '/online/authorization/user/list/all',
    method: 'GET',
    params
  })
}

export function lockUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}/lock`,
    method: 'POST'
  })
}

export function unlockUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}/unlock`,
    method: 'POST'
  })
}

export function addUser(data) {
  return request({
    url: `/online/authorization/user`,
    method: 'POST',
    data
  })
}

export function editUser(data) {
  return request({
    url: `/online/authorization/user/${data.userId}`,
    method: 'POST',
    data: data
  })
}

export function deleteUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}`,
    method: 'DELETE'
  })
}

export function getUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}`,
    method: 'get'
  })
}

export function editUserEmail(data) {
  return request({
    url: `/online/authorization/user/email/update`,
    method: 'post',
    data
  })
}

export function sendVerifyCode(data) {
  return request({
    url: `/online/authorization/user/auth-code/email`,
    method: 'post',
    data
  })
}

export function changePassword(data) {
  return request({
    url: `/online/authorization/auth/password/change`,
    method: 'POST',
    data
  })
}

export function getTimeStamp() {
  return request({
    url: `/online/authorization/auth/timestamp`
  })
}

export function getCountryList() {
  return request({
    url: `/online/authorization/country/list`,
    method: 'GET',
    params: {
      status: 1
    }
  })
}

export function getVerifyCode() {
  return request({
    url: `/online/authorization/auth/verify/code/password/self/check`,
    method: 'GET'
  })
}

export function resetRamKey(userId, data) {
  return request({
    url: `/online/authorization/ram/security/${userId}/reset`,
    method: 'POST',
    data
  })
}

export function getRamKey(userId, data) {
  return request({
    url: `/online/authorization/ram/security/${userId}/show`,
    method: 'POST',
    data
  })
}

// 通过characterCode获取对应的keyId和username
export function getUserKeyId(params) {
  return request({
    url: `/online/flycare/admin/user/list`,
    method: 'get',
    params: params
  })
}
// 检查用户是否有绑定 OA Id
export function checkUser(operatorId) {
  return request({
    url: `/online/flycare/admin/user/check/${operatorId}`,
    method: 'get'
  })
}

export function editUserName(userId, data) {
  return request({
    url: `/online/authorization/user/${userId}/?updateRoleFlag=false`,
    method: 'POST',
    data
  })
}

export function getUserManagerCountries(userId) {
  return request({
    url: `/online/developer-admin/user/${userId}/manage/country`,
    method: 'GET'
  })
}
export function getUserPermission(userId) {
  return request({
    url: `/online/authorization/user/${userId}/menu-permission`,
    method: 'GET'
  })
}

export function saveUserManagerCountries(userId, data) {
  return request({
    url: `/online/developer-admin/user/${userId}/manage/country`,
    method: 'POST',
    data
  })
}
